import typescript from "@rollup/plugin-typescript";
import PluginVue from "rollup-plugin-vue";
import { nodeResolve } from "@rollup/plugin-node-resolve";
import commonjs from "@rollup/plugin-commonjs";
import { terser } from "rollup-plugin-terser";
import babel from "@rollup/plugin-babel";

const packageJson = require("./package.json");

export default {
	input: "src/index.ts",
	output: {
		file: packageJson.main,
		format: "umd",
		name: "ExposureVue",
		globals: { vue: "Vue" },
		sourcemap: true,
	},
	plugins: [
		nodeResolve(),
		commonjs(),
		typescript({
			tsconfig: "./tsconfig.json",
		}),
		PluginVue({
			target: 2.7,
			runtimeModuleName: "vue-demi",
		}),
		babel({
			babelHelpers: "runtime",
			extensions: [".js", ".ts"],
			exclude: "node_modules/**",
			presets: [
				[
					"@babel/preset-env",
					{
						corejs: 3,
						useBuiltIns: "usage",
						targets: {
							browsers: ["> 1%", "last 2 versions", "not ie <= 11"],
						},
					},
				],
			],
			plugins: ["@babel/plugin-transform-runtime"],
		}),
		terser(),
	],
	external: ["vue"],
};
